package com.lavegue.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.lavegue.common.BaseHibernateDao;
import com.lavegue.common.Page;
import com.lavegue.dao.BisTypeDao;
import com.lavegue.model.BisType;

/**
 * author: tinazhifen
 * date:2011-12-21
 * description:
 *
 */
public class BisTypeDaoImpl extends BaseHibernateDao<BisType, Integer> implements BisTypeDao {

	public BisTypeDaoImpl() {
		super(BisType.class);
	}
	//根据分类名称查询
    public Page<BisType> getAllBisTypeByName(int pageNo,int pageSize,String name)
    {
    	List<Criterion> condition = new ArrayList<Criterion>();
		if(null != name && !name.trim().equals("")){
		   condition.add(Restrictions.like("name", name, MatchMode.ANYWHERE));
		}
		Page<BisType> page = this.findPage(pageNo, pageSize, condition, Order.desc("id"));
		return page;
    }
}

